package edu.sctu.wulixia.month6.day20150615;

import java.io.*;

/**
 * Created by user05 on 2015/6/15.
 */
public class File_Reader {

    public void isCreateFile(File file){
        if (!file.exists()){
            file.mkdir();
            System.out.println("文件夹创建成功");
        }else{
            System.out.println("文件夹已存在");
        }
    }
    public String isCreateDocument(File file) throws IOException {
        file.createNewFile();
        String path =  file.getAbsolutePath();
        FileWriter fileWriter = new FileWriter(path);
        fileWriter.write("哈哈哈！！端午要放假！！");
        fileWriter.close();
        return path;

    }

    public void isReadData(File file) throws IOException {

        FileReader fileReader = new FileReader(file);
        char data[] = new char[2048];
        int count ;

        try {
            while ((count = fileReader.read(data)) != -1){
                System.out.println(count);
                String str = new String(data,0,count);
                System.out.println(str);
            }

            fileReader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
